#!/usr/bin/env python
# coding: utf-8

# http://docs.python.org/tut/

#=============================================
knights = {'gallahad': 'the pure', 'robin': 'the brave'}
for k, v in knights.iteritems():
  print k, v

for i, v in enumerate(['tic', 'tac', 'toe']):
  print i, v

#=============================================
questions = ['name', 'quest', 'favorite color']
answers = ['lancelot', 'the holy grail', 'blue']
for q, a in zip(questions, answers):
  print 'What is your %s?  It is %s.' % (q, a)

for i in reversed(xrange(1,10,2)):
  print i

basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
for f in sorted(set(basket)):
  print f

#=============================================

x = int(raw_input("Please enter an integer: "))
if x < 0:
      x = 0
      print 'Negative changed to zero'
elif x == 0:
     print 'Zero'
elif x == 1:
     print 'Single'
else:
     print 'More'
#=============================================

# Measure some strings:
a = ['cat', 'window', 'defenestrate']
for x in a:
  print x, len(x)
#cat 3
#window 6
#defenestrate 12
#=============================================
a = ['Mary', 'had', 'a', 'little', 'lamb']
for i in range(len(a)):
    print i, a[i]

for i,j in enumerate(a):
  print i,j

#0 Mary
#1 had
#2 a
#3 little
#4 lamb
#=============================================

# finaliza somente com interrupção via teclado
#while True:
#       pass

#=============================================
